﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Zhang.IDALFactory
{
    public class UCenterAccess<T> where T : class
    {
        /// <summary>
        /// DAL DLL文件名
        /// </summary>
        //private static string WebDAL = " Zhang.DAL.UCenter";

        private static readonly string WebDal = "Zhang." + (string.IsNullOrEmpty(ConfigurationManager.AppSettings["WebDAL"]) ? "SQLServer" : ConfigurationManager.AppSettings["WebDAL"]) + ".UCenter";

        public static T CreateDal(string type)
        {
            string className = WebDal + "." + type;
            try
            {
                T t = (T)Assembly.Load(WebDal).CreateInstance(className);
                return t;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
        }

    }
}
